BigDFT.Interop.BabelInterop module
This module contains some wrappers for using OpenBabel to perform various operations on BigDFT molecules.
https://open-babel.readthedocs.io/en/latest/UseTheLibrary/Python.html
- convert_system_to_babel(sys)[source]
Convert a BigDFT system to an open babel molecule.
- Parameters:
sys (BigDFT.Systems.System) – the system to convert.
- Returns:
an open babel type molecule.
- Return type:
(openbabel.OBMol)
- convert_babel_to_system(mol)[source]
Convert a BigDFT fragment to an open babel molecule.
- Parameters:
mol (openbabel.OBMol) – the molecule to convert.
- Returns:
bigdft system.
- Return type:
- compute_babel_matching(sys, bsys, check_matching=True)[source]
Similar to the cannonical compute matching of the system class, this creates a lookup table mapping each atom in a system class to the index of the atom in a babel system.
- Parameters:
sys (BigDFT.Systems.System) – the bigdft system.
bsys (openbabel.openbabel.OBMol) – the openbabel version of the system.
check_matching (bool) – if set to True, this will raise an error if we can’t match all of the atoms in the system.
- Returns:
- a mapping from a system to indices in the atom list. If
an atom is not in the list, an index value of -1 is assigned.
- Return type:
(dict)
- build_from_smiles(smi, form='smi')[source]
Build a system from its smiles representation.
smi (str): the smiles string. form (str): the format of the smiles (either “smi” or “can”)
- compute_smiles(sys, form='smi')[source]
Computes the SMILES representation of a given system.
- Parameters:
sys (BigDFT.System.Systems) – the system to compute the representation of.
- Returns:
the smiles representation of this molecule.
- Return type:
(str)
- compute_fingerprint(sys, fps='fp2')[source]
Computes the fingerprint for a particular fragment.
- Parameters:
sys (BigDFT.Systems.System) – the fragment to compute the representation of.
fps (str) – the type of finger print to compute.
- Returns:
a fingerprint for this fragment.
- Return type:
(openbabel.OBFingerprint)
- generate_connectivity(sys)[source]
Generate the connectivity matrix for a system.
- Parameters:
sys (BigDFT.Systems.System) – the system to generate for.
- get_partial_charges(sys, charge_model='gasteiger')[source]
Assign partial charges to a system using OpenBabel’s charge models.
- Parameters:
sys (BigDFT.Systems.System) – the system to update.
- system_energy(sys, forcefield='MMFF94', verbose=False)[source]
Compute the energy of a system using an openbabel forcefield.
- Parameters:
sys (BigDFT.Systems.System) – the system to compute.
forcefield (str) – the type of forcefield to use.
verbose (bool) – whether to have openbabel run in verbose mode.
- Returns:
the energy value computed in Hartree.
- Return type:
(float)
- optimize_system(sys, forcefield='MMFF94', method='SteepestDescent', steps=1000, econv=1e-06, verbose=False)[source]
Optimize the geometry of a given fragment.
- Parameters:
- Returns:
a new fragment with the optimized positions.
- Return type:
- molecular_dynamics(sys, steps, temperature, forcefield='MMFF94', timestep=0.001, verbose=False)[source]
Run molecular dynamics on a given fragment..
- Parameters:
sys (BigDFT.Systemtems.System) – the system to run.
steps (int) – the number of MD steps to take.
temperature (float) – temperature in K.
forcefield (str) – the type of forcefield to use.
timestep (float) – time step in picoseconds.
constraints (list) – for each atom, list whether it if frozen or not.
verbose (bool) – if True, the openbabel output will be printed.
- Returns:
a new system with the optimized positions.
- Return type:
- compute_system_forces(sys, forcefield='MMFF94', verbose=False)[source]
Assign the forces of a system using an openbabel forcefield.
- Parameters:
sys (BigDFT.Systems.System) – the system to compute.
forcefield (str) – the type of forcefield to use.
verbose (bool) – whether to have openbabel run in verbose mode.
- Returns:
the energy of the system.
- Return type:
(float)
- add_hydrogens(sys)[source]
Add hydrogens to a BigDFT System.
This routine may be useful to complete a ligand which is not provided with hydrogen atoms, for instance coming from PDB database.
- Parameters:
sys (Systems.System) – the original system without hydrogens.
- Returns:
- the system with hydrogen included.
Hydrogens should preserve the residue identification in the case of a pdb. This should be controlled to avoid mistakes in the choice of tautomers.
- Return type:
- atomic_partial_charges(system=None, pdbfile=None, forcefield='mmff94')[source]
Generate a system which stores the atomic partial charges in the atoms.
- Parameters:
sys (Systems.System) – the system to analyze.
pdbfile (str) – path of the file to analyze.
forcefield (str) – force field to define the partial charges with.
- Returns:
system with the partial charges provided.
- Return type:
- split_system_by_rotamers(sys)[source]
This module will split a system into fragments based on the Rotamers.
- Parameters:
sys (BigDFT.Systems.System) – the system to split
- Returns:
the split up system.
- Return type:
- _example()[source]
The following is an example of module usage:
"""Example of using OpenBabel interoperability""" from BigDFT.Systems import System from BigDFT.Fragments import Fragment from BigDFT.IO import XYZReader # Read in a system. sys = System() sys["FRA:1"] = Fragment() with XYZReader("CH4") as ifile: for at in ifile: sys["FRA:1"] += Fragment([at]) # We can compute the smiles representation. print(compute_smiles(sys)) # The energy. print(system_energy(sys, forcefield="UFF")) # Extract the forces. compute_system_forces(sys, forcefield="UFF") for frag in sys.values(): for at in frag: print(at.get_force()) # Optimize the geometry. sys2 = optimize_system(sys, forcefield="UFF") print(system_energy(sys2, forcefield="UFF"))